import com.zl.component.UserComponent;
import com.zl.configuration.UserConfiguration;
import com.zl.controller.*;
import com.zl.model.User;
import com.zl.repository.UserRepository;
import com.zl.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class APP {
    public static void main(String[] args) {

        ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        BeanLifeComponent component=context.getBean("beanlife",BeanLifeComponent.class);
        component.use();
        //关闭容器
        context.destroy();

        //1.得到Spring上下文对象
        //ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");

        //2.使用getBean得到Bean对象 [使用注解默认的命名规则是类名小驼峰]
//        UserController userController= context.getBean("userController",UserController.class);
//        UserService userService=  context.getBean("userService",UserService.class);
//        UserRepository userRepository=context.getBean("userRepository", UserRepository.class);
//        UserComponent userComponent=context.getBean("userComponent",UserComponent.class);
//        UserConfiguration userConfiguration=context.getBean("userConfiguration",UserConfiguration.class);
//        SController sController=context.getBean("SController",SController.class);
//        //3.操作Bean对象
//        userController.sayHello();
//        userService.doService();
//        userRepository.doUserRepository();
//        userComponent.doUserComponent();
//        userConfiguration.doUserConfiguration();
//        sController.doSController();

//        User user=context.getBean("setUser1",User.class);
//
//        System.out.println("id:"+user.getId()+" name:"+ user.getName());


//        UserController userController=context.getBean("userController",UserController.class);
//        userController.sayHello();

//          UserController2 userController2=context.getBean("userController2",UserController2.class);
//          userController2.doController2();

//            UserController userController=context.getBean("userController",UserController.class);
//            userController.doUseController();
//        ScopeController scopeController=context.getBean("scopeController",ScopeController.class);
//        scopeController.doScope();
//        System.out.println();
//        ScopeController2 scopeController2=context.getBean("scopeController2",ScopeController2.class);
//        scopeController2.doScope();
    }
}
